package com.course.action;

import java.io.IOException;


import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.course.delegate.UserMgrDelegate;
import com.course.exception.ConnectionException;
import com.course.exception.DataNotFoundException;
import com.course.util.CoreList;
import com.course.util.UtilConstants;



public class CourseFacultyAction extends HttpServlet {

	
	private static final long serialVersionUID = 1L;


public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	           }
public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		 String path="";
		 CoreList vqb=null;

		  try{
			  
			  int cid=Integer.parseInt(request.getParameter("courseid"));
			  
			  System.out.println("in Action class Courseid is..........."+cid);
			 
			    String path1=request.getRealPath("/userimages");
			    System.out.println("in Action Class Path is ...................."+path1);
			  
			 try{
			  
			   vqb= new UserMgrDelegate().getFaculty(path1,cid);
			   System.out.println("in CourseFaculty Actoon ..................Faculty"+vqb);
			 }catch (DataNotFoundException e) {
				e.printStackTrace();
			}catch (ConnectionException e) {
				e.printStackTrace();
			}
			  System.out.println("in Action class vcb Feedback..........."+vqb);
			  
			  
			  if(!vqb.isEmpty()){
				  request.setAttribute("status",UtilConstants._FACULTY_INFO);
				  request.setAttribute("FacultyInfo", vqb);
				  path=UtilConstants._VIEW_FACULTY;
				 }
			  else {
				  request.setAttribute("status",UtilConstants._NO_FACULTY_INFO);
				  path=UtilConstants._VIEW_FACULTY;
				  }
			  }
		  catch (Exception e) {
			  request.setAttribute("status",UtilConstants._INVALIED_DATA);
			  path=UtilConstants._VIEW_FACULTY;
			e.printStackTrace();
		}
		RequestDispatcher rd=request.getRequestDispatcher(path);
			rd.forward(request,response);
			}

}
